class Solution {
public:
    string modifyString(string s) 
    {
        if (s.size()==1)
        {
            if (s[0]=='?')
                s[0]='a';
            return s;
        }
        for (int i=0;i<s.size();i++)
        {
            if (s[i]=='?')
            {
                for (char c='a';c<='z';c++)
                {
                    if (i==0)
                    {
                        if (c!=s[i+1])
                        {
                            s[i]=c;
                            break;
                        }
                        continue;
                    }
                    if (i==s.size())
                    {
                        if (c!=s[i-1])
                        {
                            s[i]=c;
                            break;
                        }
                        continue;
                    }
                    if (c!=s[i-1]&&c!=s[i+1])//i-1和i+1不能超出范围
                    {
                        s[i]=c;
                        break;
                    }     
                }        
            }
        }
        return s;  
    }
};
